package com.example.security.provider;


import com.example.security.domain.ShiroUserDetail;
import com.example.security.provider.base.UserProvider;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UsernamePasswordToken;

/**
 * @Author: lex
 * @Date: 2019/2/1
 */
@Slf4j
public abstract class AbstractFormUserProvider implements UserProvider {

    public AuthenticationInfo doGetAuthenticationInfo(UsernamePasswordToken token) throws AuthenticationException{
        log.warn("现在为表单登入");
        ShiroUserDetail shiroUserDetail = this.getUserDetail(token);
        return new SimpleAuthenticationInfo(shiroUserDetail, shiroUserDetail.getPassword(), shiroUserDetail.getLoginName());
    }

}
